package org.jeecg.modules.mes.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.modules.mes.entity.MesProductionPlan;
import org.jeecg.modules.mes.entity.MesProductionPlanTask;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Description: 生产计划详情VO
 * @Author: jeecg-boot
 * @Date: 2025-01-21
 * @Version: V1.0
 */
@Data
@ApiModel(value = "MesProductionPlanVO", description = "生产计划详情VO")
public class MesProductionPlanVO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    private String id;

    @ApiModelProperty(value = "计划编号")
    private String planNo;

    @ApiModelProperty(value = "关联订单ID")
    private String orderId;

    @ApiModelProperty(value = "关联订单编号")
    private String orderNo;

    @ApiModelProperty(value = "计划名称")
    private String planName;

    @ApiModelProperty(value = "生产模板ID")
    private String templateId;

    @ApiModelProperty(value = "生产模板名称")
    private String templateName;

    @ApiModelProperty(value = "计划类型(1-模板生成,2-自定义创建)")
    private Integer planType;

    @ApiModelProperty(value = "计划开始日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date planStartDate;

    @ApiModelProperty(value = "计划结束日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date planEndDate;

    @ApiModelProperty(value = "计划生产数量")
    private Integer planQuantity;

    @ApiModelProperty(value = "实际生产数量")
    private Integer actualQuantity;

    @ApiModelProperty(value = "状态(0-待审核,1-已审核,2-已下发,3-已领取,4-生产中,5-已完成,6-已取消)")
    private Integer status;

    @ApiModelProperty(value = "状态名称")
    private String statusName;

    @ApiModelProperty(value = "计划负责人")
    private String planManager;

    @ApiModelProperty(value = "优先级(1-低,2-中,3-高)")
    private Integer priority;

    @ApiModelProperty(value = "优先级名称")
    private String priorityName;

    @ApiModelProperty(value = "领取人ID")
    private String claimedBy;

    @ApiModelProperty(value = "领取人姓名")
    private String claimedByName;

    @ApiModelProperty(value = "领取时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date claimedTime;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "创建人")
    private String createBy;

    @ApiModelProperty(value = "创建日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty(value = "更新人")
    private String updateBy;

    @ApiModelProperty(value = "更新日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty(value = "工种任务列表")
    private List<MesProductionPlanTask> tasks;

    @ApiModelProperty(value = "完成进度百分比")
    private Double progressPercentage;

    @ApiModelProperty(value = "总预计工时")
    private Integer totalEstimatedHours;

    @ApiModelProperty(value = "总实际工时")
    private Integer totalActualHours;

    /**
     * 从实体类转换为VO
     */
    public static MesProductionPlanVO fromEntity(MesProductionPlan entity) {
        if (entity == null) {
            return null;
        }
        
        MesProductionPlanVO vo = new MesProductionPlanVO();
        vo.setId(entity.getId());
        vo.setPlanNo(entity.getPlanNo());
        vo.setOrderId(entity.getOrderId());
        vo.setOrderNo(entity.getOrderNo());
        vo.setPlanName(entity.getPlanName());
        vo.setTemplateId(entity.getTemplateId());
        vo.setTemplateName(entity.getTemplateName());
        vo.setPlanType(entity.getPlanType());
        vo.setPlanStartDate(entity.getPlanStartDate());
        vo.setPlanEndDate(entity.getPlanEndDate());
        vo.setPlanQuantity(entity.getPlanQuantity());
        vo.setActualQuantity(entity.getActualQuantity());
        vo.setStatus(entity.getStatus());
        vo.setPlanManager(entity.getPlanManager());
        vo.setPriority(entity.getPriority());
        vo.setClaimedBy(entity.getClaimedBy());
        vo.setClaimedByName(entity.getClaimedByName());
        vo.setClaimedTime(entity.getClaimedTime());
        vo.setRemark(entity.getRemark());
        vo.setCreateBy(entity.getCreateBy());
        vo.setCreateTime(entity.getCreateTime());
        vo.setUpdateBy(entity.getUpdateBy());
        vo.setUpdateTime(entity.getUpdateTime());
        
        return vo;
    }
}
